import execjs

# python 运行js代码
# js_str = '''
# function shuffleString(str) {
#         // 将字符串转换为数组
#         const arr = str.split('');
#
#         // Fisher-Yates 洗牌算法
#         for (let i = arr.length - 1; i > 0; i--) {
#             const j = Math.floor(Math.random() * (i + 1));
#             // 交换元素
#             [arr[i], arr[j]] = [arr[j], arr[i]];
#         }
#
#         // 将数组转换回字符串
#         return arr.join('');
#     }
# '''
# info = input('输入字符串')
# js_code = execjs.compile(js_str)
# r = js_code.call('shuffleString', info)
# print(r)

# js_str = '''
# function _0x2de6(_0x29bd99, _0x49bbd0) {
#     var _0x169399 = _0x3041();
#     return _0x2de6 = function (_0x3b5909, _0xbba88a) {
#         _0x3b5909 = _0x3b5909 - (-0x1 * -0xf94 + 0x5c8 * -0x5 + -0x2 * -0x72a);
#         var _0x2fe893 = _0x169399[_0x3b5909];
#         return _0x2fe893;
#     }, _0x2de6(_0x29bd99, _0x49bbd0);
# }
# (function (_0xee991b, _0x405258) {
#     var _0x3f7724 = _0x2de6, _0x125b7a = _0xee991b();
#     while (!![]) {
#         try {
#             var _0x366990 = parseInt(_0x3f7724(0x101)) / (0x1cb5 + 0x819 * -0x3 + -0x469 * 0x1) + parseInt(_0x3f7724(0x10a)) / (0x75b + 0x13df * -0x1 + 0x2 * 0x643) * (parseInt(_0x3f7724(0x105)) / (0x49a * -0x5 + -0x1e4 + 0x38f * 0x7)) + parseInt(_0x3f7724(0x103)) / (-0x2340 + -0x55e * -0x1 + 0x1de6) + -parseInt(_0x3f7724(0x109)) / (0xb77 * 0x1 + -0x16c4 + -0x2a * -0x45) + -parseInt(_0x3f7724(0x10b)) / (-0x34c + -0x2344 + 0x2696 * 0x1) + -parseInt(_0x3f7724(0x100)) / (0x61a + 0x8a2 + 0x5 * -0x2f1) * (parseInt(_0x3f7724(0x104)) / (-0x749 * 0x2 + -0x1f + -0xeb9 * -0x1)) + parseInt(_0x3f7724(0x106)) / (0x7b9 + 0x6a * -0x5c + 0x1e68);
#             if (_0x366990 === _0x405258)
#                 break;
#             else
#                 _0x125b7a['push'](_0x125b7a['shift']());
#         } catch (_0x2b7455) {
#             _0x125b7a['push'](_0x125b7a['shift']());
#         }
#     }
# }(_0x3041, -0x1e43f * -0x7 + 0x10f508 + -0x9084 * 0x26));
# function _0x3041() {
#     var _0x72a213 = [
#         '4851120ZOllox',
#         '41504uZxygH',
#         '451770TTbMYb',
#         '1631QjSEWI',
#         '832391xFdzaY',
#         'kJfgP',
#         '3086580MoWhmZ',
#         '25720HzAGJI',
#         '45oQYRxU',
#         '4072707CExwav',
#         'RuZUv',
#         'helloworld'
#     ];
#     _0x3041 = function () {
#         return _0x72a213;
#     };
#     return _0x3041();
# }
# function say_hi(_0x5414eb) {
#     var _0x6523dd = _0x2de6, _0x27fcd4 = {
#             'kJfgP': function (_0x418b58, _0x3dc94c) {
#                 return _0x418b58 + _0x3dc94c;
#             },
#             'RuZUv': _0x6523dd(0x108)
#         };
#     return _0x27fcd4[_0x6523dd(0x102)](_0x27fcd4[_0x6523dd(0x107)], _0x5414eb);
# }
# '''
# info = input('输入字符串')
# js_code = execjs.compile(js_str)
# r = js_code.call('say_hi', info)
# print(r)


# js_str = '''
# var window={
#     navigator:{
#     'userAgent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36'
#     },
#     document:{
#     'cookie':'csrftoken=P48pOiT2m8MKXSFMk9eXxwYaR2vrdKgG'
#     }
# };
# function _0x1d97() {
#         const _0x4c5872 = [
#             '13503AEVghj',
#             '2291397wxDUQI',
#             '14010slofkC',
#             'wSovr',
#             '2QUGVwD',
#             'document',
#             '2616616JVQFCD',
#             'userAgent',
#             '21867065kedApH',
#             '33346yRtPra',
#             'cookie',
#             '1350YjFjFh',
#             'navigator',
#             '1909060cLHlnm',
#             '63TFkogP',
#             '2824GjsJpV'
#         ];
#         _0x1d97 = function () {
#             return _0x4c5872;
#         };
#         return _0x1d97();
#     }
#
#     (function (_0x3346a3, _0x3f2d19) {
#         const _0x5b85e9 = _0x1e32, _0x2ce5fb = _0x3346a3();
#         while (!![]) {
#             try {
#                 const _0x1466e3 = parseInt(_0x5b85e9(0x1ff)) / (-0x151b + -0x2534 + 0x3a50) * (parseInt(_0x5b85e9(0x1f4)) / (-0x617 * 0x1 + -0x18e4 + 0x1efd * 0x1)) + parseInt(_0x5b85e9(0x1fc)) / (-0x212c + -0xa68 + 0x2b97) + parseInt(_0x5b85e9(0x1f1)) / (-0x503 * 0x1 + 0xb * -0xe1 + 0xeb2) + -parseInt(_0x5b85e9(0x1f6)) / (0x1 * -0x2072 + -0x4 * -0x955 + -0xf * 0x53) * (parseInt(_0x5b85e9(0x1fd)) / (-0xc62 + 0x36c + 0x8fc)) + -parseInt(_0x5b85e9(0x1fb)) / (-0x10c7 + -0x1 * 0x67d + 0x174b) * (-parseInt(_0x5b85e9(0x1fa)) / (0x20b1 + 0x1d39 * 0x1 + -0x3de2)) + -parseInt(_0x5b85e9(0x1f9)) / (-0x1d66 + 0x1 * 0x136a + -0x3 * -0x357) * (-parseInt(_0x5b85e9(0x1f8)) / (0xb * 0x1f9 + 0xfdd * 0x1 + 0x2 * -0x12c3)) + -parseInt(_0x5b85e9(0x1f3)) / (0x1ccb + -0x1 * 0x119e + -0xb22);
#                 if (_0x1466e3 === _0x3f2d19)
#                     break;
#                 else
#                     _0x2ce5fb['push'](_0x2ce5fb['shift']());
#             } catch (_0x3d6003) {
#                 _0x2ce5fb['push'](_0x2ce5fb['shift']());
#             }
#         }
#     }(_0x1d97, -0xec4bf + 0xa02a4 * -0x1 + 0x25c088));
#
#     function _0x1e32(_0x487b0f, _0x594521) {
#         const _0x299101 = _0x1d97();
#         return _0x1e32 = function (_0x567f7b, _0x498baf) {
#             _0x567f7b = _0x567f7b - (-0x215b + 0x20bb + 0x2 * 0x148);
#             let _0x3d323c = _0x299101[_0x567f7b];
#             return _0x3d323c;
#         }, _0x1e32(_0x487b0f, _0x594521);
#     }
#
#     function useragent_cookie(_0x462b87) {
#         const _0x1fab45 = _0x1e32, _0x389bb5 = {
#             'wSovr': function (_0xc1f4fe, _0x54b15e) {
#                 return _0xc1f4fe + _0x54b15e;
#             }
#         };
#         let _0x2b0ee5 = _0x389bb5[_0x1fab45(0x1fe)](_0x389bb5[_0x1fab45(0x1fe)](window[_0x1fab45(0x1f7)][_0x1fab45(0x1f2)], _0x462b87), window[_0x1fab45(0x1f0)][_0x1fab45(0x1f5)]);
#         return _0x2b0ee5;
#     }
# '''
#
# info = input('输入字符串')
# js_code = execjs.compile(js_str)
# r = js_code.call('useragent_cookie', info)
# print(r)


with open('./parse/1.js逆向原理.js', 'r', encoding='utf-8') as f:
    js_str = f.read()

info = input('输入字符串')
js_code = execjs.compile(js_str, cwd='./parse')
r = js_code.call('crypto_str', info)
print(r)
